# include "scene.h"

# include <stdio.h>
# include <stdlib.h>
# include <math.h>

/* This function accepts the temperature in Kelvin and returns kinematic viscosity of the water. */
extern double kvisc(double T)
  {
   FILE *ptr;

#  ifdef RETURN_CONST_KVISC
   T = T_INIT;
#  endif

   T -= ABS_ZERO;

   if(T < 0 || T > 100)
     {
#     ifdef _OPENMP_
      #pragma omp critical
#     endif
        {
         if((ptr = (FILE *)fopen("kvisc_log.txt", "w")) == (FILE*)0) ptr = stdout;

         fprintf(ptr, "ERROR:: In function 'kvisc()': \"T = %E Kelvin\"; However, it should be \"%E K <= T <= %E K\"\n",\
                      T+ABS_ZERO, 0+ABS_ZERO, 100+ABS_ZERO);

         if(ptr != stdout) fclose(ptr);
         exit(-1);
        }
     }

   return 2.67E-7 + 1.481E-6*exp(-0.03381*T);
  }
